package com.xiaochong.bitong.job.schedule;

import com.netflix.discovery.converters.Auto;
import com.xc.logclient.utils.LogTrace;
import com.xiaochong.bitong.job.config.ExecutorConfig;
import com.xiaochong.bitong.job.service.KActionSectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Description: 定时处理k线数据
 * @Author: org
 * @CreateDate: 2018/8/17 11:02
 */
@Component
public class KActionSectionScheduled {

    @Autowired
    private KActionSectionService kActionSectionService;

  /*  @Async(ExecutorConfig.SCHEDULER_EXECUTOR_POOL)
    @Scheduled(cron="40 0/5 * * * ?")
    public void calculateFiveMKAction() throws Exception {
        LogTrace.beginTrace();
        long start = System.currentTimeMillis();
        LogTrace.info("thread-交易对5分钟k线start","start",String.valueOf(start));
        kActionSectionService.calculateFiveMKAction();
        LogTrace.info("thread-交易对5分钟k线end","end",String.valueOf(System.currentTimeMillis()-start));
        LogTrace.info("thread-交易对5分钟k线end","end",String.valueOf(System.currentTimeMillis()-start));
    }

    *//**
     * 4h的k线数据
     * @throws Exception
     *//*
    @Async(ExecutorConfig.SCHEDULER_EXECUTOR_POOL)
    @Scheduled(cron="0 5 0,4,8,12,16,20 * * ?")
    public void calculateFourHKAction() throws Exception {
        LogTrace.beginTrace();
        long start = System.currentTimeMillis();
        LogTrace.info("thread-交易对4Hk线start","start",String.valueOf(start));
        kActionSectionService.calculateFourHKAction();
        LogTrace.info("thread-交易对4Hk线end","end",String.valueOf(System.currentTimeMillis()-start));
    }
*/
    /**
     * 时时资金净流入每日0点计算昨日数据，保存到mysql中
     * @throws Exception
     */
    @Async(ExecutorConfig.SCHEDULER_EXECUTOR_POOL)
    //@Scheduled(cron="0 1,13,57 0/1 * * ?")
    @Scheduled(cron="0 0/5 * * * ?")
    public void calculateYesFlow() throws Exception {
        LogTrace.beginTrace();
        long start = System.currentTimeMillis();
        LogTrace.info("thread-昨日资金净流入start","start",String.valueOf(start));
        kActionSectionService.calculateYesFlow();
        LogTrace.info("thread-昨日资金净流入end","end",String.valueOf(System.currentTimeMillis()-start));
    }
}
